package Servlet;

import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import Dao.BanDao;
import Service.Servlet;
import vo.User;


@WebServlet("/addxs")
public class AddxsServlet extends HttpServlet {
	private static final long serialVersionUID = 1L;
	private Servlet a = new Servlet(); 
	
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		request.setCharacterEncoding("UTF-8");
		String username = request.getParameter("username");
		String password = request.getParameter("password");
		String name = request.getParameter("name");
		String sex = request.getParameter("sex");
		Integer cless_id = Integer.parseInt(request.getParameter("bjid"));
		String post = request.getParameter("post");
		
		BanDao dao = new BanDao();
		User re = new User(username,password,name,sex,dao.FindById(cless_id),post);
	
		a.addxs(re);
		response.sendRedirect("student");
	}

	
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		doGet(request, response);
	}

}
